<?php

namespace app\qgroup\controller;

use app\common\service\SysConfigService;
use app\qgroup\model\GroupMemberMapping;
use app\qgroup\service\CodeFactory;
use app\qgroup\service\TulingService;

/**
 * Class Message
 * @var $serviceTulingService TulingService
 * @package app\qgroup\controller
 */

class Message extends Base
{
    /**
     * @var $serviceTulingService TulingService
     */
    public function index()
    {
        $cf = new CodeFactory();
        $code = $cf->getDecCode('PUITMdZyfJSXnaF');
        var_dump($code);
    }

    public function single()
    {
        $qq = input('qq');
        $fqq = input('fqq');
        $msg = input('msg');
        $msgID = input('msgId');
        $type = input('type');
        $gmm = GroupMemberMapping::get(['qq'=>$fqq]);
        $result = $this->serviceTulingService->getReturnData($fqq,$type == 'image'? 1 :($type == 'text' ? 0 : ($type == 'record'? 2: 0)),$msg,$gmm->area);
        trace($result);
        $result = $this->serviceTulingService->sendMessage(json_encode($result));
        trace($result);
        $result = json_encode($result,true);

    }

    public function group()
    {
        $qgroup = input('qgroup');
        $fqq = input('fqq');
        $msg = input('msg');
        $anonymousId = input('anonymousId');        #匿名
        $anonymousName = input('anonymousName');        #匿名
        $msgID = input('msg');

    }

    public function test()
    {
        $res = $this->serviceXiaoIService->sendMessage('question=你好&userId=aaa',SysConfigService::getURLConfig('A_XIAOI'));
        var_dump($res);
    }
}
